package com.hmy.finance.service.core;

import com.hmy.ccp.common.response.BasePageResponse;
import com.hmy.finance.bo.request.ReceivablesQueryRequest;
import com.hmy.finance.bo.response.ReceivablesExportResponse;
import com.hmy.finance.bo.response.ReceivablesQueryResponse;
import com.hmy.finance.dal.po.DeviceDailyBillPo;
import com.hmy.finance.dal.po.DeviceRentalRecordPo;
import com.hmy.finance.dal.po.ReceivableInventoryPo;
import com.hmy.finance.service.core.dto.DailyInvoiceGenerationJobDto;
import com.hmy.finance.service.rdto.ContractTotalReceivableRdto;

import java.time.LocalDate;
import java.util.List;

/**
 * @author songkf
 * @description 针对表【receivable_Inventory(应收盘点)】的数据库操作Service
 * @createDate 2024-02-21 18:55:01
 */
public interface IReceivableInventoryService {

    /**
     * 分页查询应收盘点
     */
    BasePageResponse<ReceivablesQueryResponse> queryReceivablesByPage(ReceivablesQueryRequest receivablesQueryRequest);

    /**
     * 应收盘点导出
     */
    ReceivablesExportResponse exportReceivablesByParams(ReceivablesQueryRequest receivablesExportRequest);

    /**
     * 处理应收盘点
     *
     * @param dto 每日流水处理任务数据传输对象
     * @return 是否处理成功
     * @author songkf
     */
    Boolean handleReceivableInventory(DailyInvoiceGenerationJobDto dto);

    /**
     * Retrieves a list of receivable inventory POs that are waiting for offset.
     *
     * @param customerId the ID of the customer
     * @param contractId the ID of the contract
     * @param startDate  the start date for filtering
     * @param endDate    the end date for filtering
     * @return a list of receivable inventory POs
     */
    List<ReceivableInventoryPo> selectWaitOffsetList(Long customerId, Long contractId, LocalDate startDate, LocalDate endDate);


    /**
     * 查询合同总欠款金额
     */
    List<ContractTotalReceivableRdto> queryContractTotalReceivableAmountByContractIds(List<Long> contractIds);

    Boolean updateOffsetThroughDate(Long id, LocalDate localDate);

    ReceivableInventoryPo getReceivableInventoryByContractId(Long contractId);

    void calculateReceivableInventoryPeriodAmount(ReceivableInventoryPo receivableInventoryPo, List<DeviceRentalRecordPo> deviceRentalRecordList);

    Boolean refreshReceivableInventory(Long contractId, List<DeviceDailyBillPo> allDeviceDailyBillPoList, List<DeviceRentalRecordPo> deviceRentalRecordPoList);
}
